<?
    /* -*- Mode: PHP5; tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- */
    
    /*********************************************************
    *            --== InArch ==--
    *
    * @author Kulikov Alexey <a.kulikov@gmail.com>
    * @version n/a
    * @since 25.05.2005
    * @copyright essentialmind.com 2005
    *
    *********************************************************/
    
    /***
    * Class adminFactory
    ****
    * This is a factory object, that generates other objects, which
    * represent various portions of the admin panel.
    ****
    * @package adminNodes
    * @author A Kulikov <a.kulikov@gmail.com>
    * @version n/a
    * @since 25.05.2005
    * @copyright essentialmind.com 2005
    ***/
    class adminNodeFactory{
        
        /**
         * @param string $name   - Name of the section in the admin panel
         * @param object $db     - Reference to the database object
         * @param object $smarty - Reference to the template parser
         * @param object $log    - Reference to the log writer
         * @return 
         **/
        public static function cast($name, ADOConnection $db, MySmarty $smarty, $log){
            //see if the needed class file exists
            if (file_exists(INA_ROOT.'classes'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'adminNode' . ucfirst($name) . '.class.php') or 
                file_exists(ROOT.'classes'.DIRECTORY_SEPARATOR.'adminNode' . ucfirst($name) . '.class.php')) {
                
                //figure out class name
                $className = 'adminNode' . ucfirst($name);
                
                //cast the new object and return it to the caller
                return new $className($db,$smarty,$log);
                
            //no joy, the class file does not exist
            }else{
                //raise an exception!
                throw new Exception ('Requested Admin Node Module "'.$name.'" was not found!',404);
            }
        }
    }
?>